package com.SouthernWall_404.age_tool.common.event;

import com.SouthernWall_404.age_tool.common.world.block.TriggerBlocks.LeftClickTriggerBlock;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;

public class onLeftClick {

    @SubscribeEvent
    public static void onRightClick(PlayerInteractEvent.LeftClickBlock event)
    {
        Level level=event.getLevel();
        BlockPos blockPos=event.getPos();
        Block block=level.getBlockState(blockPos).getBlock();
        if(block instanceof LeftClickTriggerBlock leftClickTriggerBlock)
        {
            leftClickTriggerBlock.triggered(level,blockPos);
            event.setCanceled(true);
        }

    }
}
